﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Clothes_OrderPay.aspx.cs"
    Inherits="School.Pages.Uniforms.Clothes_OrderPay" MasterPageFile="~/MasterALSafa.Master"%>

<%@ Register Src="../UserControls/CampusPackage.ascx" TagName="CampusPackage" TagPrefix="uc1" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript">
     function CallPrint(strid) {
         var prtContent = document.getElementById(strid);
         var WinPrint = window.open('', '', 'letf=0,top=0,width=550,height=550,toolbar=0,scrollbars=0,status=0');
         WinPrint.document.write('<div dir=rtl>' + prtContent.innerHTML + '</div>');
         WinPrint.document.close();
         WinPrint.focus();
         WinPrint.print();
         WinPrint.close();

     }</script>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" >
            <ContentTemplate>
                <table>
                    <tr>
                        <td>
                            <asp:Panel ID="PanelAdd" runat="server">
                                <table align="right" dir="rtl">
                                    <tr>
                                        <td colspan="2">
                                            <uc1:CampusPackage ID="CampusPackage1" runat="server" />
                                        </td>
                                        <td colspan="2">
                                            <uc1:CampusPackage ID="CampusPackage2" runat="server" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 85px;">
                                            الزى
                                        </td>
                                        <td>
                                            <asp:DropDownList Width="148" ID="ddlClothes" DataValueField="Id" DataTextField="Name"
                                                runat="server" AutoPostBack="True" OnTextChanged="ddlClothes_TextChanged" AppendDataBoundItems="True">
                                                <asp:ListItem Value="0">اختيار</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td>
                                            اسم الطالب
                                        </td>
                                        <td style="padding-right:20px;">
                                            <asp:DropDownList Width="148" ID="ddlStudents" DataValueField="Id" DataTextField="FullName"
                                                runat="server" AppendDataBoundItems="True" AutoPostBack="True" OnSelectedIndexChanged="ddlStudents_SelectedIndexChanged">
                                                <asp:ListItem Value="0">اختيار</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 85px;">
                                            المقاس
                                        </td>
                                        <td>
                                            <asp:DropDownList Width="148" ID="ddlSizes" DataValueField="Size_Id" DataTextField="SizeName"
                                                runat="server" AppendDataBoundItems="True">
                                                <asp:ListItem Value="0">اختيار</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td style="width: 64px; height: 28px; padding-top: 15px; text-align: center" class="admintitle">
                                            الخصومات
                                        </td>
                                        <td align="right" rowspan="2">
                                            <asp:GridView ID="gvDiscountApplay" runat="server" Width="300" CssClass="Grid" HeaderStyle-CssClass="GridHeaderFooter"
                                                FooterStyle-CssClass="GridHeaderFooter" PagerStyle-CssClass="GridPager" AlternatingRowStyle-CssClass="GridItemAltername"
                                                AutoGenerateColumns="False" DataKeyNames="Id">
                                                <AlternatingRowStyle CssClass="GridItemAltername" />
                                                <Columns>
                                                    <asp:TemplateField>
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="ChkDiscount" runat="server" />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="الخصم">
                                                        <ItemTemplate>
                                                            <asp:Label ID="Name" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                                                            <asp:Label ID="LblDiscountId" Visible="false" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="النوع">
                                                        <ItemTemplate>
                                                            <asp:Label ID="Type" runat="server" Text='<%# GetType(Eval("Type")) %>'></asp:Label>
                                                            <asp:Label Visible="false" ID="LblType" runat="server" Text='<%# Eval("Type") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="القيمة">
                                                        <ItemTemplate>
                                                            <asp:Label ID="Value" runat="server" Text='<%# GetValue(Eval("Type"),Eval("Value")) %>'></asp:Label>
                                                            <asp:Label Visible="false" ID="LblValue" runat="server" Text='<%# Eval("Value") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <FooterStyle CssClass="GridHeaderFooter" />
                                                <HeaderStyle CssClass="GridHeaderFooter" />
                                                <PagerStyle CssClass="GridPager" />
                                            </asp:GridView>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 85px;">
                                            الكميه
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtValue" onkeypress="return FilterInt(this, event)" Width="143"
                                                runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                                                    runat="server" ErrorMessage="*" ControlToValidate="txtValue" ValidationGroup="bu"
                                                    ForeColor="Red"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                        <div style="float: right; width: 120px; padding-left: 0; padding-right: 50px; padding-top: 10px;">
                                                <asp:Button ID="btnGetDiscounts" CssClass="graybutton" runat="server" 
                                                    Text="الخصومات" ValidationGroup="bu"
                                                    Width="81px" onclick="btnGetDiscounts_Click"  /></div>
                                            <div style="float: right; width: 230px; padding-left: 0; padding-right: 15px; padding-top: 10px;">
                                                <asp:Button ID="btnAdd" CssClass="graybutton" runat="server" Text="اضافه" ValidationGroup="bu" Width="81px"
                                                    OnClick="btnAdd_Click" /></div>
                                         
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4" style="color: Green">
                                            <asp:Literal ID="lblResult" runat="server"></asp:Literal>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="5">
                                            <asp:GridView ID="gvData" runat="server" AutoGenerateColumns="False"
                                                OnRowCommand="gvData_RowCommand" OnRowDeleting="gvData_RowDeleting" CssClass="Grid"
                                                HeaderStyle-CssClass="GridHeaderFooter" FooterStyle-CssClass="GridHeaderFooter"
                                                PagerStyle-CssClass="GridPager" AlternatingRowStyle-CssClass="GridItemAltername">
                                                <Columns>
                                                    <asp:BoundField DataField="CampusName" HeaderText="المجمع" />
                                                    <asp:BoundField DataField="CerName" HeaderText="الشهاده" />
                                                    <asp:BoundField DataField="StageName" HeaderText="المرحله" />
                                                    <asp:BoundField DataField="GradeName" HeaderText="الصف" />
                                                    <asp:BoundField DataField="ClotheName" HeaderText="الزى" />
                                                    <asp:BoundField DataField="SizeName" HeaderText="المقاس" />
                                                    <asp:BoundField DataField="PriceName" HeaderText="سعر الوحده" />
                                                    <asp:BoundField DataField="UserQty" HeaderText="الكميه" />
                                                    <asp:BoundField DataField="TotalPrice" HeaderText="اجمالى" />
                                                    <asp:BoundField DataField="DiscountPercent" HeaderText="الخصم" />
                                                    <asp:BoundField DataField="PriceWzDiscount" HeaderText="اجمالى بعد الخصم" />
                                                    <asp:TemplateField ShowHeader="False">
                                                        <ItemTemplate>
                                                            <asp:LinkButton ID="LnkDelete" runat="server" CommandName="DoDelete" Text="حذف"></asp:LinkButton>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                            </asp:GridView>
                                        </td>
                                    </tr>
                              </table>
                            </asp:Panel>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div>
        <table align="right" runat="server" dir="rtl">
            <tr>
                <td colspan="4">
                     <div style="float: right; padding-right: 170px; padding-top: 20px;">
                        <asp:Button  ID="btnpayment" runat="server" CssClass="graybutton" OnClick="btnpayment_Click"
                            TabIndex="13" Text="إنشاء أمر دفع" />
                    </div>
                </td>
            </tr>
            <tr>
                <td nowrap="nowrap" colspan="4">
                    <input type="hidden" clientidmode="Static"  id="hshow" runat="server" />
                    <div id="rptDiv">
                        <asp:ObjectDataSource ID="OdsDiscount" runat="server" OnSelecting="OdsDiscount_Selecting"
                            SelectMethod="PrintOrderDiscount" TypeName="School.Service.Clothes.SRV_CLothe"
                            OldValuesParameterFormatString="original_{0}">
                            <SelectParameters>
                                <asp:Parameter Name="DiscountLst" Type="Object" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        <asp:ObjectDataSource ID="OdsGrdData" runat="server" OnSelecting="OdsGrdData_Selecting"
                            SelectMethod="PrintOrderDataGrd" TypeName="School.Service.Clothes.SRV_CLothe"
                            OldValuesParameterFormatString="original_{0}">
                            <SelectParameters>
                                <asp:Parameter Name="GrdLst" Type="Object" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        <asp:ObjectDataSource ID="OdsOrder" runat="server" OnSelecting="OdsOrder_Selecting"
                            SelectMethod="PrintOrder" TypeName="School.Service.Clothes.SRV_CLothe" OldValuesParameterFormatString="original_{0}">
                            <SelectParameters>
                                <asp:Parameter Name="stu_Name" Type="String" />
                                <asp:Parameter Name="CamName" Type="String" />
                                <asp:Parameter Name="CerName" Type="String" />
                                <asp:Parameter Name="StageName" Type="String" />
                                <asp:Parameter Name="GradeName" Type="String" />
                                <asp:Parameter Name="PayNum" Type="Int64" />
                                <asp:Parameter Name="Price" Type="Decimal" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt"
                            InteractiveDeviceInfos="(Collection)" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"
                            SizeToReportContent="True">
                            <LocalReport ReportPath="Uniforms\Reports\rpt_Clothes_PayOrder.rdlc">
                                <DataSources>
                                    <rsweb:ReportDataSource DataSourceId="OdsOrder" Name="DSPayOrder" />
                                    <rsweb:ReportDataSource DataSourceId="OdsDiscount" Name="DsDiscount" />
                                    <rsweb:ReportDataSource DataSourceId="OdsGrdData" Name="DsGrd" />
                                </DataSources>
                            </LocalReport>
                        </rsweb:ReportViewer>
                    </div>
                    <script language="javascript" type="text/javascript">
                        if ($('#hshow').val() == '1') {
                            $('#rptDiv').show();
                        }
                        else {
                            $('#rptDiv').hide(); 
                        }
                    </script>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
